package com.china.bank.demo.controller;

import com.china.bank.demo.dto.BankDto;
import com.china.bank.demo.service.BankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Description: 一个Restful服务（接口） .<br>
 *
 * @author m-xy
 *     Created By 2019/10/22 14:47
 */
@Api(tags = "银行管理")
@RestController
public class BankController {
    @Autowired private BankService bankService;

    /**
     * 银行信息查询 .
     *
     * @return ResponseEntity.
     */
    @RequestMapping(value = "/banks", method = RequestMethod.GET,
                    produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("银行信息查询")
    public ResponseEntity<List<BankDto>> queryBanks(
        @RequestParam(required = false) String name) {
        return ResponseEntity.ok(bankService.queryBanks(name));
    }
}
